package org.opengeoingest.tufts.Layer;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.fileupload.FileItem;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 * read in FGDC formated file into a hashtable representation 
 * this hash can be used to generate a solr file.
 * This class is build on BaseBeoParser.  Here we only have to specify the FGDC tag names 
 * that correspond to fields needed for searching. 
 *  
 * @author smcdon08
 *
 */
public class FgdcParser extends BaseGeoParser
{

	public FgdcParser(String filename)
	{
		super(filename);
	}
	
	public FgdcParser(FileItem fileItem)
	{
		super(fileItem);
	}

	
	/**
	 * passed key is the name of a Solr field, returned value is the corresponding FGDC tag name
	 */
	public String keyToTag(Key key)
	{
		if (key == Key.Title)
			return "title";
		else if (key == Key.Abstract)
			return "abstract";
		else if (key == Key.WestBc)
			return "westbc";
		else if (key == Key.EastBc)
			return "eastbc";
		else if (key == Key.NorthBc)
			return "northbc";
		else if (key == Key.SouthBc)
			return "southbc";
		else if (key == Key.EsriName)
			return "ftname";
		else if (key == Key.Publisher)
			return "publish";
		else if (key == Key.Originator)
			return "origin";
		else if (key == Key.ThemeKeywords)
			return "themekey";
		else if (key == Key.PlaceKeywords)
			return "placekey";
		else if (key == Key.Access)
			return "accconst";
		else 
		{
			System.out.println("error in FgdcToSolr.keyToFgdcTag, unexpected key = " + key);
			return "error";
		}
		
	}

}
